"""add_snapshot_table

Revision ID: 4fb45aa624d9
Revises: 60a9fc91f469
Create Date: 2025-08-20 00:34:44.901506

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '4fb45aa624d9'
down_revision: Union[str, None] = '60a9fc91f469'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_change_log_id', table_name='change_log')
    op.drop_index('ix_change_log_seq', table_name='change_log')
    op.drop_index('ix_change_log_type', table_name='change_log')
    op.drop_index('ix_change_log_version', table_name='change_log')
    op.drop_table('change_log')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('change_log',
    sa.Column('seq', sa.BIGINT(), server_default=sa.text("nextval('global_seq'::regclass)"), autoincrement=True, nullable=False),
    sa.Column('ts', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
    sa.Column('type', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
    sa.Column('id', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('version', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('payload', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('seq', name='change_log_pkey')
    )
    op.create_index('ix_change_log_version', 'change_log', ['version'], unique=False)
    op.create_index('ix_change_log_type', 'change_log', ['type'], unique=False)
    op.create_index('ix_change_log_seq', 'change_log', ['seq'], unique=False)
    op.create_index('ix_change_log_id', 'change_log', ['id'], unique=False)
    # ### end Alembic commands ###
